package scalab.filters.selectors

import scalab.utils.Path

/**
* Selects all the files whose canonical path starts with a given prefix.
*/

trait StartsWith extends scalab.core.component.Selector

object StartsWith{
	import scalab.core.dependencies.Dependency
	def apply(componentName: String, suffix: String, staticDeps: Iterable[Dependency]): StartsWith = new StartsWith{
		override def select(d: Dependency): Boolean = d.canonicalPath.startsWith(Path(suffix))
		override val name: String = componentName
		override val staticDependencies = staticDeps
	}

	def apply(prefix: String, staticDeps: Iterable[Dependency]): StartsWith = apply("StartsWith", prefix, staticDeps)
	def apply(componentName: String, prefix: String): StartsWith = apply(componentName, prefix, Nil)
	def apply(prefix: String): StartsWith = apply(prefix, Nil)
}
